package com.hkemmm.common.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Value("${spring.datasource.mysql.driver-class-name}")
    private String mysql_driverClassName;
    @Value("${spring.datasource.mysql.url}")
    private String mysql_url;
    @Value("${spring.datasource.mysql.username}")
    private String mysql_username;
    @Value("${spring.datasource.mysql.password}")
    private String mysql_password;

    @Bean
    public DataSource getDataSource() {
        DruidDataSource dataSource = new DruidDataSource();

        dataSource.setDriverClassName(mysql_driverClassName);
        dataSource.setUrl(mysql_url);
        dataSource.setUsername(mysql_username);
        dataSource.setPassword(mysql_password);


        return dataSource;
    }
}
